package com.huabo.contract.mysql.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.contract.mysql.entity.TblContractAppendixsigningMySql;
import com.huabo.contract.mysql.mapper.TblContractAppendixsigningMySqlMapperSqlConifg;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.*;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huabo
 * @since 2021-10-29
 */
public interface TblContractAppendixsigningMySqlMapper extends BaseMapper<TblContractAppendixsigningMySql> {

	@Select("SELECT TAC.SINGINGID,TAC.SINGINGNAME,TAC.SINGINGPATH,TAC.SINGINGSIZE,TAC.PDFVIEWFILEPATH,TAC.SINGINGTYPE,TAC.SINGINGSTATUS,TAC.CONSTRACTID,TAC.UPLOADTIME,TAC.UPLOADER,TS.REALNAME FROM TBL_CONTRACT_APPENDIXSIGNING TAC LEFT JOIN TBL_STAFF TS ON TAC.UPLOADER = TS.STAFFID WHERE CONSTRACTID = #{contractid}")
	@Results({
		@Result(column="SINGINGID",property="singingId"),
		@Result(column="SINGINGNAME",property="singingName"),
		@Result(column="PDFVIEWFILEPATH",property="pdfViewFilePath"),
		@Result(column="SINGINGPATH",property="singingPath"),
		@Result(column="SINGINGSIZE",property="singingSize"),
		@Result(column="SINGINGTYPE",property="singingType"),
		@Result(column="SINGINGSTATUS",property="singingStatus"),
		@Result(column="CONSTRACTID",property="constractId"),
		@Result(column="UPLOADTIME",property="uploadTime"),
		@Result(column="UPLOADER",property="uploader"),
		@Result(column="REALNAME",property="uploaderName"),
	})
	List<TblContractAppendixsigningMySql> findFileListByContractId(@Param("contractid") BigDecimal contractid) throws Exception;

	@Select("SELECT COUNT(0) FROM TBL_CONTRACT_APPENDIXSIGNING WHERE CONSTRACTID = #{contractId}")
	Integer findFileCountByContractId(String contractId); 	

	@SelectProvider(type=TblContractAppendixsigningMySqlMapperSqlConifg.class,method="findFileListByContractIdPageInfo")
    List<TblContractAppendixsigningMySql> findFileListByContractIdPageInfo(PageInfo<TblContractAppendixsigningMySql> pageInfo);

	@SelectProvider(type=TblContractAppendixsigningMySqlMapperSqlConifg.class,method="findCountFileListByContractIdPageInfo")
	Integer findCountFileListByContractIdPageInfo(PageInfo<TblContractAppendixsigningMySql> pageInfo);

	@Select("SELECT * FROM TBL_CONTRACT_APPENDIXSIGNING WHERE SINGINGID = #{singingId}")
	TblContractAppendixsigningMySql findBysingingId(Integer singingId);

	@Delete("DELETE FROM TBL_CONTRACT_APPENDIXSIGNING WHERE SINGINGID = #{singingId}")
	void deleteBySingingId(Integer singingId);

	@Insert("INSERT INTO TBL_CONTRACT_APPENDIXSIGNING(SINGINGNAME,SINGINGPATH,SINGINGSIZE,SINGINGTYPE,SINGINGSTATUS,CONSTRACTID,UPLOADTIME,UPLOADER) VALUES(#{singingName},#{singingPath},#{singingSize},#{singingType},#{singingStatus},#{constractId},#{uploadTime},#{uploader})")
	void saveEntity(TblContractAppendixsigningMySql signing);
}
